########################################################################
#  Pyfm - personal finance data-base
#  Copyright (C) 2007,8 Ehud Ben-Reuven
#  udi@benreuven.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#########################################################################
"""Wrapper for pickle module. I've found that cPickle.dump has a bug that does not allow it to work directly in a sub-packge
so whenvever a module  in one of the sub packages when to save something it should call the dump located here."""
import cPickle
#import pickle
pickle=cPickle # This allows you to switch between pickle and cPickle moduels

def dump(obj,fname):
		output = open(fname,'wb')
		pickle.dump(obj,output,pickle.HIGHEST_PROTOCOL)
		output.close()
		

def load(fname):
	pkl_file = open(fname,'rb')
	obj = pickle.load(pkl_file)
	pkl_file.close()
	return obj
